{include file="public/header"}
</head>
<body>
<div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> 订单详情</strong> <a href="" style="float:right; display:none;">添加字段</a>
    </div>
    <div class="padding border-bottom">
        <form id="F" action="">
            <ul class="search" style="padding-left:10px;">
                <li><b>用户</b> : {$list['nickname']}</li>
                <li><b>收货人</b> : {$list['aname']}</li>
                <li><b>手机</b> : {$list['atel']}</li>
                <li><b>收货地址</b> : {$list['sheng']} {$list['city']} {$list['quyu']} {$list['address']}</li>
                <li><b>订单状态</b> : <font color="#00CC99">{$list['order_status']}</font></li>
                <li><b>下单时间</b> : {:date('Y-m-d H:i:d',$list['addtime'])}</li>
            </ul>
        </form>
    </div>
    <table class="table table-hover text-center" oid="{$list['id']}">
        <tr>
            <th width="20%">商品名</th>
            <th width="10%">商品图片</th>
            <th width="10%">原价</th>
            <th width="10%">本店价</th>
            <th width="5%">数量</th>
            <th width="10%">小计</th>
        </tr>
        {foreach $op as $v}
        <tr>
            <td>{$v['name']}</td>
            <td><img src="/static/{$v['photo_x']}" alt="" width="70" height="50"/></td>
            <td><s>¥{$v['pprice']}元</s></td>
            <td>¥{$v['price_shop']}元</td>
            <td>{$v['num']}</td>
            <td>{$v['price_shop']*$v['num']}</td>
        </tr>
        {/foreach}
        <tr>
            <td colspan="6" style="text-align:right;padding-right:20px;">
                <b>原价</b> : <s>¥{$list['price']}元</s> &nbsp; &nbsp; &nbsp;
                <b>优惠价</b> :¥{$list['amount']}元 &nbsp; &nbsp; &nbsp;
                {if $list['status']==11}
                <input type="text" name="" class="input w50" id="dh" placeholder="请填写物流单号">
                <a class="button bg-main icon-arrow-up" id="deliver">去发货</a>
                {elseif $list['status']==21/}
                <b>退款金</b> :¥<b>{$list['refundMoney']}</b>元
                <b>退款原因</b> :{$list['refundReamrk']}
                <a class="button bg-main icon-arrow-up" id="back">同意退款</a>
                <a class="button bg-main icon-arrow-up" id="noback">拒绝退款</a>
                {/if}
            </td>
        </tr>
    </table>
    <script>
        $('#deliver').click(function () {
            var oid = $(this).parent().parent().parent().parent().attr('oid');
            var dh = $(this).prev().val();
            if (dh==""){
                alert('请填写物流单号')
            }else{
                $.ajax({
                    type:'post',
                    url:'{:url("Order/deliver")}',
                    data: {id:oid,dh:dh},
                    dataType:'json',
                    success: function (data) {
                        if (data){
                            alert('发货成功');
                            window.location.reload();
                        }else {
                            alert('网络波动')
                        }
                    }
                })
            }
        })
        $('#back').click(function () {
            var oid = $(this).parent().parent().parent().parent().attr('oid');
            var money = $(this).prev().prev().text();
            console.log(money);
            if(confirm("您确定要同意退款吗?")){
                $.ajax({
                    type:'post',
                    url:'{:url("Order/backMoney")}',
                    data: {id:oid,money:money},
                    dataType:'json',
                    success: function (data) {
                        if (data){
                            alert('退款成功');
                            window.location.reload();
                        }else {
                            alert('网络波动')
                        }
                    }
                })
            }
        })
        $('#noback').click(function () {
            var oid = $(this).parent().parent().parent().parent().attr('oid');
            if(confirm("您确定要拒绝退款吗?")){
                $.ajax({
                    type:'post',
                    url:'{:url("Order/nobackMoney")}',
                    data: {id:oid},
                    dataType:'json',
                    success: function (data) {
                        if (data){
                            alert('拒绝成功');
                            window.location.reload();
                        }else {
                            alert('网络波动')
                        }
                    }
                })
            }
        })



    </script>
</div>
</body>
</html>